/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 *
 * $Id: TGIMI_PROTOCOL_AVANT_SIMCMD.h,v 1.1 2007-04-18 12:22:34 amaula Exp $
 *
 */
#ifndef _TGIMI_PROTOCOL_AVANT_SIMCMD_H_
#define _TGIMI_PROTOCOL_AVANT_SIMCMD_H_
#include "owndebug.h"

struct TGIMI_PROTOCOL_AVANT_SIMCMD
{
public:
  /**
   * Ground model to use with simulator.
   *
   */
  enum EGroundModel { groundModelFlat, groundModelHeightmap };
  
  TGIMI_PROTOCOL_AVANT_SIMCMD()
    : loadweight(0.00),
      groundmodel(0.0),
      friction(0.5) {}


  /**
   * Select ground model to use.
   * 
   * @param[in] aModel          Groundmodel to use. @See EGroundModel
   */
  void SetGroundModel(const EGroundModel aModel) {
    switch(aModel) {
    case groundModelFlat:
      groundmodel = 0.00;
      break;
    case groundModelHeightmap:
      groundmodel = 1.00;
      break;
    }
  }


  /**
   * Set the load in kilograms.
   *
   * @param[in] aLoad           Load to place in the bucket. In kilograms.
   *                            Maximum load is 300.00kg. Values larger will
   *                            be truncated. Minimum load is 0.00kg.
   *
   */
  void SetLoad(const float aLoad) {
    loadweight = aLoad/300.0;
    if (loadweight > 1.00) loadweight = 1.00;
    if (loadweight < 0.00) loadweight = 0.00;
  }
  

  /**
   * Returns the currently set Load.
   *
   * @return                    Currently set Loadweight in kilograms.
   
   */
  float GetLoad(void) const {
    return (loadweight * 300.0);
  }


  /**
   * Set the friction value. 
   *
   * @param[in] aFriction       Friction value to set. Values ranging from
   *                            0.00 - 1.00. If Friction is Zero (The default in 
   *                            simulator, the machine will not move :)
   *
   */
  void SetFriction(const float aFriction) {
    friction = aFriction;
    if (friction > 1.00) friction = 1.00;
    if (friction < 0.00) friction = 0.00;
  }
  

  /**
   * Returns the currently set Friction.
   *
   * @return                    Currently set friction value.
   */
  float GetFriction(void) const {
    return friction;
  }


  /**
   * Print the packet content.
   *
   * @param[in] aLvl            Debug level to use.
   *
   */
  void Print(const int aLvl) const {
    dPrint(aLvl, 
	   "Loadweight: %.4f (%.2fkg), groundmod: %.1f ('%s') Friction: %.1f\r\n", 
	   loadweight, loadweight*300.0, 
	   groundmodel, groundmodel == 1.00 ? "HeightMap" : "Flat", 
	   friction);
  }
  
public:
  float loadweight;	        ///< Mass (0...1)
  float groundmodel;	        ///< Switch between groundModels (0 or 1)
  float friction;	        ///< The friction between the wheel and ground (0...1)
};


#endif //_TELEUDPHEADER_HPP_
